import App from './App'

// #ifndef VUE3
import Vue from 'vue'
import store from './store'
Vue.config.productionTip = false
Vue.prototype.$store = store
App.mpType = 'app'

Vue.filter('transformNumber', function(number){
	if(10000 < number && number < 100000000){
		number /= 10000
		number = number.toFixed(1)
		return `${number}万`
	}else if(number > 100000000){
		number /= 100000000
		number = number.toFixed(1)
		return `${number}亿`
	}else return number
})

Vue.filter('timeFormat', function(time){
	var date = new Date(time)
	let y = date.getFullYear()
	let m = date.getMonth()
	let d = date.getDay()
	let h = date.getHours()
	let mi = date.getMinutes()
	let s = date.getSeconds()
	h = h < 10 ? `0${h}` : h
	mi = mi < 10 ? `0${mi}` : mi
	s = s < 10 ? `0${s}` : s
	let nowDate = new Date()
	let nd = nowDate.getDay()
	if(nd - d == 1){
		let nh = nowDate.getHours()
		let nmi = nowDate.getMinutes()
		let ns = nowDate.getSeconds()
		nh = nh < 10 ? `0${nh}` : nh
		nmi = nmi < 10 ? `0${nmi}` : nmi
		ns = ns < 10 ? `0${ns}` : ns
		return `昨天 ${nh}:${nmi}:${ns}`
	}
	let newTime = `${y}年${m+1}月${d+1}日${h}:${mi}:${s}`
	return newTime
})

const app = new Vue({
    ...App,
	store
})
app.$mount()
// #endif

// #ifdef VUE3
import { createSSRApp } from 'vue'
export function createApp() {
  const app = createSSRApp(App)
  return {
    app
  }
}
// #endif